package com.mtsmda.ws.rest.jboss.services;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;

@Path("/user")
public class UserRestrictService {

	private static final Integer STATUS_200 = 200;

	@GET
	public Response simpleUser() {
		return Response.status(STATUS_200).entity(new String("SImple user"))
				.build();
	}

	@GET
	@Path("/vip")
	public Response vipUser() {
		return Response.status(STATUS_200).entity("VIP user").build();
	}

	@GET
	@Path("{name}")
	public Response getUserByName(@PathParam("name") String name) {
		String user = "User name is - " + name;

		return Response.status(STATUS_200).entity(user).build();
	}

	@GET
	@Path("{id : \\d+}")
	public Response getUserById(@PathParam("id") String idUser) {
		String userById = "User id is - " + idUser;

		return Response.status(STATUS_200).entity(userById).build();
	}

	@GET
	@Path("/username/{userName : [a-zA-Z][a-zA-Z_0-9]}")
	public Response getUserName(@PathParam("userName") String userName) {
		String un = "RegExp - username is - " + userName;

		return Response.status(STATUS_200).entity(un).build();
	}

	@GET
	@Path("/book/{isbn : \\d+}")
	public Response getBookByISBN(@PathParam("isbn") String isbn) {
		String bI = "Book isbn is - " + isbn;

		return Response.status(STATUS_200).entity(bI).build();
	}

	@GET
	@Path("/date/{day}/{month}/{year}")
	public Response getArticleByDate(@PathParam("day") int day,
			@PathParam("month") int month, @PathParam("year") int year) {

		String article = "This is simple article, see for example - " + day + "." + month + "." + year;
		
		return Response.status(STATUS_200).entity(article).build();
	}

}